package com.bao123.email.controller;

import com.bao123.email.service.VerificationCodeService;
import com.bao123.redis.service.RedisStringService;
import com.bao123.utils.constant.GeneralResultConstant;
import com.bao123.utils.result.GeneralResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 验证码控制器
 * @author lbw
 */
@RestController
@RequestMapping("verificationCodeController")
public class VerificationCodeController {

    @Autowired
    private VerificationCodeService verificationCodeService;
    @Autowired
    private RedisStringService redisStringService;

    @RequestMapping("sendVerificationCode")
    public GeneralResult<?> sendVerificationCode(String email){
        verificationCodeService.sendVerificationCode(email);
        return new GeneralResult<>(GeneralResultConstant.SUCCESS,"验证码已发送");
    }

    @RequestMapping("helloRedis")
    public String hello(){
        redisStringService.setKey("hello", "Hello Redis", 30);
        String hello = redisStringService.getValue("hello");
        return hello;
    }
}
